package chapter07

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/11 9:41 AM
 */
object Test11_CommonOp {
  def main(args: Array[String]): Unit = {
    val list = List(1, 3, 5, 6, 7, 9)
    val set = Set(23, 3, 45, 67)
    // 1.获取集合长度
    println(list.length)
    // 2.获取集合大小
    println(set.size)
    // 3.循环遍历
    for (elem <- list) {
      println(elem)
    }
    set.foreach(println)
    println("=" * 20)
    // 4.迭代器
    for (elem <- list.iterator) println(elem)
    // 5.生成字符串
    println(list)
    println(set)
    println(list.mkString(","))

    println("=" * 20)
    // 6.是否包含
    println(list.contains(2))
    println(set.contains(3))
  }
}
